""" DigitalICS: mobile data collection tool to complete surveys with integrated multimedia

    Copyright (C) 2009. Yael Schwartzman  

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>
    
    Contact information: Yael Schwartzman -  yaelsf@gmail.com
    """
from api.form import Form
from api.constants import Constants

def enform3(community,municipio,localidad,producer,num_parcels = None):
    c = Constants()
    form = Form()
    form.set_community_id(community)
    form.set_producer_id(producer)
    form.set_municipio_id(municipio)
    form.set_localidad_id(localidad)
    
    
    form.set_num_parcels(num_parcels)
    form.set_id("Section3")
    form.set_name("Soil Management and Fertilization");
    form.set_module("enform3")
    
    
    form.add_mult_data([ "protection","cover_type","erosion","how_much_erosion","conservation","practices",
         "terraces","type_terraces",'dead_barriers','live_barriers',"compost","which_compost",
         "quantity_compost","date_compost","manure", "uso_manure", "origen_manure","quantity_bushes",
         "quantity_applied","date_aplication","kilo_bushes","ts1","ts2"])
    
    form.add_prompt(label = "1. Is the soil covered by either foliage or vegetation",
                    audio = "4.1protection",
                    input_type = c.INPUT,
                    return_type = c.RETURN_BOOLEAN,
                    id = "1.cover",
                    data = "protection",
                    output= {'YES':"1. THE SOIL IS PROTECTED BY EITHER FOLIAGE OR VEGETATION",
                             'NO': "1. THE SOIL IS NOT PROTECTED BY EITHER FOLIAGE OR VEGETATION"},
                    breach = ['NO'])
    
    form.add_prompt(relevance = {'1.cover' : '== "YES"'},
                    id ="2.type",
                    data ="cover_type",
                    label = "2. Which type of cover is there in the parcel?",
                    audio = "4.1cover_type",
                    input_type = c.SELECT,
                    options = ['vegetation','foilage'],
                    output = " BY #VAR")
    
    form.add_prompt(id = "3.erosion",
                    data = "erosion", 
                    label ="3. Is there erosion in the parcel?",
                    audio = "4.2erosion_en",
                    input_type = c.INPUT,
                    return_type = c.RETURN_BOOLEAN,
                    output= {'YES':"2. THERE IS EROSION IN THE PARCEL",
                             'NO':"2. THERE IS NO EROSION IN THE PARCEL"},
                    breach = ['YES']) 
     
    form.add_prompt(relevance = {'3.erosion': '== "YES"'},
                    id = "4.how much erosion",
                     data = "how_much_erosion",
                     label = "4. How much erosion is there?",
                     audio = "4.2how_much_erosion",
                     input_type = c.SELECT1,
                     options = ['a lot of','some','a little'],
                     output = "THERE IS  #VAR EROSION IN THE PARCEL",
                     breach = ['mucha'])
    
    form.add_prompt(id = "5.conservation",
                    data = "conservation",
                    label  = "5. Did the producer do any soil conservation practices this year?",
                    audio = "4.3conservation",
                    input_type = c.INPUT,
                    return_type = c.RETURN_BOOLEAN,
                    output = {'YES': "3. THE PRODUCER DID DO SOIL CONSERVATION PRACTICES THIS YEAR",
                              'NO':  "3. THE PRODUCER DID NOT DO SOIL CONSERVATION PRACTICES THIS YEAR"})


                    
                      
    form.add_prompt(relevance = {'5.conservation': "== 'YES'"},
                     id = "6.practices",
                     data = "practices",
                     label = "6. Which practices did the producer do?",
                     audio = "4.3practices",
                     options = ['Terraces','Dead Barrier','Live Barrier'],
                     input_type = c.SELECT)
                     
       
    form.add_prompt(relevance = {'5.conservation': "== 'YES'",
                                 '6.practices':['__contains__',"'Terraces'"]},
                    label = "7. How many terraces were made?",
                    audio = "4.3how_many_terraces",
                    id = "7.terraces",
                    data = "terraces",
                    input_type = c.INPUT,
                    return_type = c.RETURN_INTEGER,
                    output = "THERE WERE #VAR TERRACES MADE")
    
   

    form.add_prompt(relevance = {'5.conservation': "== 'YES'",
                                 '6.practices':['__contains__',"'Dead Barrier'"]},
                    label = "7. How many meters of dead barriers were made?",
                    audio = "4.3qty_bm",
                    id = '7.dead_barriers',
                    data = 'dead_barriers',
                    input_type = c.INPUT,
                    return_type = c.RETURN_INTEGER,
                    output = "THERE WERE #VAR MTS. OF DEAD BARRIERS MADE")
    
    form.add_prompt(relevance = {'5.conservation': "== 'YES'",
                                 '6.practices':['__contains__',"'Live Barrier'"]},
                    label = "7. How many meters of live barriers were made?",
                    audio = "4.3qty_bv",
                    id = '7.live_barriers',
                    data = 'live_barriers',
                    input_type = c.INPUT,
                    return_type = c.RETURN_INTEGER,
                    output = "THERE WERE #VAR MTS. OF LIVE BARRIERS MADE")

    form.add_prompt(label = "8. Did the producer use either compost or worm compost?",
                    audio = "4.4compost",
                    id = "8.compost",
                    data = "compost",
                    input_type = c.INPUT,
                    return_type = c.RETURN_BOOLEAN,
                    output= {'YES':"4. THE PRODUCER USES COMPOST OR WORM COMPOST",
                             'NO':"4. THE PRODUCER DOES NOT USE COMPOST OR WORM COMPOST"})
			    


    form.add_prompt( relevance = {"8.compost" : "== 'YES'"},
                     label = "11. Number of bushes fertilized last year:",
                     audio = "4.4bushes",
                     input_type = c.INPUT,
                     return_type = c.RETURN_INTEGER,
                     id = "11.bushes",
                     data = "quantity_bushes",
                     output = "No. OF BUSHES FERTILIZED LAST YEAR: #VAR")         
    


                  
    return form
